Page({
  data:{
    appId:'',
    appName:'',
    recordId:'',
    pageTitle:'',
    pageDesc:'',
    sections:[],
    status:'pending',
    statusText:'待处理',
    metaDate:'',
    metaApplicant:''
  },
  onLoad(options){
    const appId=options.appId||options.app_id||''
    const appName=decodeURIComponent(options.appName||options.app_name||'')
    const recordId=options.recordId||''
    this.setData({appId,appName,recordId})
    this.initPage()
  },
  initPage(){
    const title=`记录详情：${this.data.appName}`
    const desc=`单号 ${this.data.recordId}`
    const sections=this.buildDetailByAppId(this.data.appId,this.data.recordId)
    const meta=this.getMetaByAppId(this.data.appId)
    this.setData({pageTitle:title,pageDesc:desc,sections,status:meta.status,statusText:meta.statusText,metaDate:meta.date,metaApplicant:meta.applicant})
  },
  getMetaByAppId(appId){
    return {status:'pending',statusText:'待处理',date:'2025-11-27',applicant:'庄嘉豪'}
  },
  buildDetailByAppId(appId,recordId){
    const id=String(appId)
    const base=(pairs)=>[{id:'base',name:'基本信息',fields:pairs}]
    if(id==='31'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`员工假期申请单-${recordId}`},
          {id:'applicant',label:'申请人',value:'庄嘉豪'},
          {id:'applyDate',label:'申请日期',value:'2025-11-27'},
          {id:'leaveType',label:'假期类型',value:'年假'},
          {id:'leaveReason',label:'请假事由',value:'个人事务'}
        ]},
        {id:'detail',name:'请假明细',fields:[
          {id:'start',label:'开始日期',value:'2025-11-28'},
          {id:'end',label:'结束日期',value:'2025-11-29'},
          {id:'slot',label:'时间段',value:'全天'}
        ]}
      ]
    }
    if(id==='38'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`差旅费报销-${recordId}`},
          {id:'applicant',label:'申请人',value:'庄嘉豪'},
          {id:'applyDate',label:'申请日期',value:'2025-11-27'},
          {id:'department',label:'申请部门',value:'信息技术部'}
        ]},
        {id:'amount',name:'费用信息',fields:[
          {id:'expenseType',label:'支出类别',value:'交通'},
          {id:'amount',label:'报销总额',value:'560.00'}
        ]}
      ]
    }
    if(id==='28'){
      return base([
        {id:'subject',label:'会议主题',value:`会议申请-${recordId}`},
        {id:'location',label:'会议地点',value:'会议室A'},
        {id:'convener',label:'召集人',value:'庄嘉豪'},
        {id:'attendees',label:'参会人员',value:'张三、李四'}
      ])
    }
    if(id==='29'){
      return base([
        {id:'title',label:'标题',value:`支出预算-${recordId}`},
        {id:'department',label:'申请部门',value:'信息技术部'},
        {id:'budgetMonth',label:'费用月份',value:'2025-11'},
        {id:'amount',label:'金额',value:'12000.00'}
      ])
    }
    if(id==='32'){
      return base([
        {id:'title',label:'标题',value:`员工辞职-${recordId}`},
        {id:'department',label:'申请部门',value:'信息技术部'},
        {id:'position',label:'职位',value:'一级助理'},
        {id:'resignReason',label:'辞职理由',value:'个人发展'},
        {id:'resignDate',label:'本人于',value:'2025-11-27'}
      ])
    }
    if(id==='36'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`物资采购-${recordId}`},
          {id:'department',label:'申请部门',value:'信息技术部'},
          {id:'supplier',label:'供应商',value:'供应商A'}
        ]},
        {id:'items',name:'采购明细',fields:[
          {id:'item',label:'物资',value:'笔记本电脑'},
          {id:'qty',label:'数量',value:'2'},
          {id:'total',label:'金额',value:'12000.00'}
        ]}
      ]
    }
    return base([
      {id:'title',label:'标题',value:`通用申请-${recordId}`},
      {id:'applicant',label:'申请人',value:'庄嘉豪'},
      {id:'date',label:'申请日期',value:'2025-11-27'}
    ])
  }
  })
